/** 病害相关的数据库初始化 */
import { TAB_DISEASES, OPTIONS_TABLE } from "../config/common.js";

/** 初始化病害表 */
export const createDiseaseTable = db => {
	const sql = `
		create table if not exists '${TAB_DISEASES}'(
			_id varchar(255),
			id int primary key,
			docId int,
			videoDocId int,
			projectId int,
			projectOrgId int,
			startMileageFront varchar(255),
			endMileageFront varchar(255),
			startMileageAfter varchar(255),
			endMileageAfter varchar(255),
			startNumber varchar(255),
			endNumber varchar(255),
			others varchar(255),
			clockwisePosition varchar(255),
			diseaseStatus varchar(255),
			diseaseGrade varchar(255),
			diseaseGradeName varchar(255),
			diseaseGradeId int,
			diseaseGradeOld varchar(255),
			diseaseStandardLibraryId int,
			diseaseMaterialId int,
			diseaseNo varchar(255),
			diseaseNoOld varchar(255),
			isSandySoil boolean,
			isInfluenceEquipment boolean,
			isProtectionSection boolean,
			deviceLocation varchar(255),
			repairMethod varchar(255),
			orderType varchar(255),
			createDate int,
			firstInspectionDate int,
			lineId varchar(255),
			lineName varchar(255),
			lineSiteSectionId varchar(255),
			lineSiteSectionName varchar(255),
			mileage varchar(255),
			lineSiteSectionType varchar(255),
			createUserId varchar(255),
			createUserName varchar(255),
			followup varchar(255),
			inspectLogId varchar(255),
			inspectUser varchar(255),
			isDelete boolean,
			rankClass varchar(255),
			recordCreateDate int,
			recordUpdateDate int,
			inspectDate int,
			reviewUserId varchar(255),
			reviewUserName varchar(255),
			alterationUserId varchar(255),
			alterationUserName varchar(255),
			diseaseChange varchar(255),
			shiftOwnership varchar(255),
			stationLocation varchar(255),
			reviewDate int,
			inputValue varchar(255),
			type varchar(255),
			diseaseRemarks varchar(255),
			_diseaseGradeId int,
			version integer default 0,
			submit integer default 0,
			code varchar(255) default '',
			repairTeam varchar(255),
			predictEndDate int,
			predictOrderNo varchar(255),
			examineExplain varchar(255),
			examineName varchar(255),
			examineResult varchar(255),
			examineTime int,
			checkName varchar(255),
			checkResult varchar(255),
			checkTime int,
			checkDesc varchar(255),
			pmId int,
			pmName varchar(255),
			projectName varchar(255),
			branchLineName varchar(255)
		);
	`;
	return db.execute(sql);
}

/** 初始化选项表 */
export const createOptionsTable = db => {
	const sql = `
		create table if not exists '${OPTIONS_TABLE}'(
			apiName varchar(255),
			value text
		);
	`;
	return db.execute(sql);
	
}